#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repd(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define forn(i,a,b) for(int i=(int)(a);i<=(int)(b);++i)
#define ford(i,a,b) for(int i=(int)(b);i>=(int)(a);--i)
#define all(S) (S).begin(),(S).end()
#define pb push_back
#define INF 0x3f3f3f3f
#define modcg(x) if(x>=mod)x-=mod
#define modcl(x) if(x<0)x+=mod
//============================================================================================
const int MAXN=1e5+10;
int n,m,LL,V;
struct car
{
    int d,v,a;
    bool operator<(const car &C)const
    {
        return d>C.d;
    }
}c[MAXN];
int p[MAXN];
int l[MAXN],r[MAXN];
int N;
pii calc(int id,int L)
{
    int d=c[id].d,v=c[id].v,a=c[id].a;
    if(a>0)
    {
        int s=(V*V-v*v)/(2*a)+1;
        int down=lower_bound(p+1,p+1+m,d+s)-p;
        return {down,m};
    }
    if(a==0)
    {
        return {L,m};
    }
    if(a<0)
    {
        int s=(v*v-V*V-1)/(-2*a);
        int down=upper_bound(p+1,p+1+m,d+s)-p-1;
        // cout<<d+s<<" "<<p[down]<<endl;
        return {L,down};
    }
}
int id[MAXN];
bool cmp(const int &x,const int &y)
{
    return l[x]!=l[y]?l[x]<l[y]:r[x]>r[y];
}
void SOLVE()
{
    cin>>n>>m>>LL>>V;
    forn(i,1,n)
    {
        cin>>c[i].d>>c[i].v>>c[i].a;
    }
    sort(c+1,c+1+n);
    forn(i,1,m)
    {
        cin>>p[i];
    }
    int d=m+1;N=0;
    forn(i,1,n)
    {
        while(d-1>=1&&p[d-1]>=c[i].d)
        {
            d--;
        }
        if(c[i].a>=0)
        {
            if(p[m]>=c[i].d&&c[i].v*c[i].v+2*c[i].a*(p[m]-c[i].d)>V*V)
            {
                pii now=calc(i,d);N++;
                l[N]=now.first;r[N]=now.second;
            }
        }
        else
        {
            if(d!=m+1&&c[i].v*c[i].v+2*c[i].a*(p[d]-c[i].d)>V*V)
            {
                pii now=calc(i,d);N++;
                l[N]=now.first;r[N]=now.second;
            }
        }
    }
    if(!N)
    {
        cout<<0<<" "<<m<<endl;
        return;
    }
    forn(i,1,N)
    {
        id[i]=i;
    }
    // forn(i,1,N)
    // {
    //     cout<<l[i]<<" "<<r[i]<<endl;
    // }
    sort(id+1,id+1+N,cmp);
    int minn=INF;
    int ans=1;
    forn(i,1,N)
    {
        if(minn<l[id[i]])
        {
            ans++;
            minn=r[id[i]];
        }
        else
        {
            minn=min(minn,r[id[i]]);
        }
    }
    cout<<N<<" "<<m-ans<<endl;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin.tie(0);cout.tie(0);std::ios::sync_with_stdio(0);
    int TEST_CASE=1;
    cin>>TEST_CASE;
    while(TEST_CASE--)
    {
        SOLVE();
    }
    return 0;
}